<?php

namespace app\advertisement\controller;

use app\common\controller\PCBase;
use app\BaseController;//测试专用
use app\advertisement\logic\AdvaccountLogic;
use think\facade\Db;
use Throwable;
use app\common\library\Upload;

class Advaccount extends PCBase
{


    public function initialize(): void
    {
        parent::initialize();
    }

    /**
     * index
     * @throws Throwable
     */
    public function index()
    {
        $params     = $this->request->post();
        $adminId    = $this->getAdminId();
        $groupId    = $this->getAdminGroupId();
        $params['adminId'] = $adminId;
        $params['groupId'] = $groupId;
        return (new AdvaccountLogic())->index($params);
    }

    
    /**
     * 添加
     * @throws Throwable
     */
    public function add()
    {
        $post = $this->request->post();
        $AdvaccountlogLogic = new AdvaccountLogic();
        $result = $AdvaccountlogLogic->add($post);
        return $result;
    }

    /**
     * 回显
     * @throws Throwable
     */
    public function find($id = null)
    {
        $post = $this->request->post();
        $id = $post['id'] ?? 0;
        $AdvaccountlogLogic = new AdvaccountLogic();
        $result = $AdvaccountlogLogic->find($id);
        return $result;
    }
    /**
     * 编辑
     * @throws Throwable
     */
    public function edit()
    {
        $post = $this->request->post();
        $AdvaccountlogLogic = new AdvaccountLogic();
        $result = $AdvaccountlogLogic->edit($post);
        return $result;
    }

    /**
     * 编辑
     * @throws Throwable
     */
    public function edit_ascription()
    {
        $post = $this->request->post();
        $AdvaccountlogLogic = new AdvaccountLogic();

        // 操作日志
        $operator = $this->getAdminId();
        $post['operator'] = $operator;

        $result = $AdvaccountlogLogic->edit_ascription($post);
        return $result;
    }
    /**
     * 编辑
     * @throws Throwable
     */
    public function del_ascription()
    {
        $post = $this->request->post();
        $AdvaccountlogLogic = new AdvaccountLogic();

        // 操作日志
        $operator = $this->getAdminId();
        $post['operator'] = $operator;

        $result = $AdvaccountlogLogic->del_ascription($post);
        return $result;
    }

    /**
     * export
     * @throws Throwable
     */
    public function export()
    {
        $params     = $this->request->post();
        $AdvaccountLogic = new AdvaccountLogic();
        return $AdvaccountLogic->export($params);
    }

    /**
     * AscriptionList归属列表
     * @throws Throwable
     */
    public function AscriptionList()
    {
        $params     = $this->request->post();
        $AdvplatformLogic = new AdvaccountLogic();
        return $AdvplatformLogic->AscriptionList($params);
    }

    /**
     * AscriptionList归属列表
     * @throws Throwable
     */
    public function Ascriptionexport()
    {
        $params     = $this->request->post();
        $AdvplatformLogic = new AdvaccountLogic();
        return $AdvplatformLogic->Ascriptionexport($params);
    }

    /**
     * @desc   通过平台获取广告账户
     * @author xx
     * @date   2024-08-28
     */
    public function getAdvistementList(){
        $params   = $this->request->post();
        return    (new AdvaccountLogic())->getAdvistementList($params);
    }




}
